<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="js/jquery-3.3.1.min.js"></script>
<script>
    function checkUserName() {
        let username = $("#username").val();
        $.post("/servlet","username="+username,function (data) {
            $("#msg").html(data);
        },"text");
    }
</script>
</head>
<body>
用户名:<input type="text" id="username" onblur="checkUserName()"/> <span id="msg" style="color: red"></span> <br>
<button>提交</button>
</body>


</html>